package com.ruibang.glass.produce.controller.bz;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.domain.req.PackagingRecordsReq;
import com.ruibang.glass.produce.entity.PackagingRecords;
import com.ruibang.glass.produce.service.PackagingRecordsService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-03-19  14:34
 * @Description: TODO
 * @Version: 1.0
 */

@Api(tags = "包装生产记录")
@RestController
@RequestMapping("/api/glass/produce/bz/packagingRecords")
public class PackagingRecordsController {

    @Autowired
    private PackagingRecordsService packagingRecordsService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "查询包装生产记录", response = ResultBody.class)
    public ResultBody<IPage<PackagingRecords>> query(@RequestBody PackagingRecordsReq packagingRecordsReq) {
        return ResultBody.success(packagingRecordsService.pageQuery(packagingRecordsReq));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 3, target = FrequencyControl.Target.IP)
    public void export(@RequestBody PackagingRecordsReq packagingRecordsReq, HttpServletResponse response) {
        packagingRecordsService.export(packagingRecordsReq, response);
    }


//    @GetMapping("/get")
//    @ApiOperation(value = "", response = ResultBody.class)
//    public ResultBody get() {
//        try {
//            Thread.sleep(1000);
//            Robot robot = new Robot();
//            int x = 1205;
//            int y = 40;
//            robot.mouseMove(x, y);
//
//            Thread.sleep(1000);
//
//            // 模拟鼠标左键点击
//            robot.mousePress(InputEvent.BUTTON1_MASK);
//            robot.mouseRelease(InputEvent.BUTTON1_MASK);
//
//            Thread.sleep(1000);
//
//            // 移动鼠标到另一个位置
//            robot.mouseMove(780, 480);
//
//            Thread.sleep(1000);
//
//            // 模拟鼠标左键点击
//            robot.mousePress(InputEvent.BUTTON1_MASK);
//            robot.mouseRelease(InputEvent.BUTTON1_MASK);
//
//            Thread.sleep(15000);
//
//            robot.mouseMove(897, 41);
//
//            robot.mousePress(InputEvent.BUTTON1_MASK);
//            robot.mouseRelease(InputEvent.BUTTON1_MASK);
//            robot.mousePress(InputEvent.BUTTON1_MASK);
//            robot.mouseRelease(InputEvent.BUTTON1_MASK);
//            robot.mousePress(InputEvent.BUTTON1_MASK);
//            robot.mouseRelease(InputEvent.BUTTON1_MASK);
//
//        } catch (AWTException | InterruptedException e) {
//            e.printStackTrace();
//        }
//        return ResultBody.success();
//    }


}
